/* eslint-disable eqeqeq *///忽略==的警告
import { homeDeng } from "../api/index"
import { saveGroupInfor, stringTo16 } from './homeUtils';
import { getOctets2Msg } from './dataUtils';
import PubSub from 'pubsub-js'
import { meshLog, SPRemove, SPGet, SPSet } from "../config";

//这个是关于home界面的area device subgroup ungroup中的调光调色的方法集合
//area的 dim的方法
export const areaLightDim = async (innertexts, addr) => {
    meshLog('innertexts', innertexts);
    let value16 = parseInt(innertexts).toString(16)
    meshLog('value16', value16);
    let groupSetx = JSON.parse(SPGet("groupSetx"));
    //修改localStorage上areaSetx的数据
    let groupItem;
    for (let index = 0; index < groupSetx.length; index++) {
        if (groupSetx[index].groupId == addr) {
            groupItem = groupSetx[index]
        }
    }

    meshLog(groupItem);
    const valueonff = value16 + '0A'
    const groupStatusX = groupItem.groupStatus.slice(0, 2) + value16 + groupItem.groupStatus.slice(4, 28);
    //meshLog('valueonff', valueonff);
    let value1 = '25251600006101000000000003' + groupItem.groupId + '00000000000000' + '1110' + valueonff;
    let logo = stringTo16(value1)
    let value = value1 + logo + '5252'
    meshLog('logologo', logo);
    var data = ',' + groupItem.wangguanMac + ',' + value + ',';
    //修改数据库中的数据
    let groupSetx1 = saveGroupInfor(groupItem, groupStatusX)
    meshLog('调亮度修改之后的数据',);
    PubSub.publish('showUpdate', data)//控制mqtt数据发送
    PubSub.publish('data', groupItem)

}
//area的tem 的方法
export const areaLightTem = async (temtem, address, rgbH) => {
    let areaSetx = JSON.parse(SPGet("areaSetx"));

    let areaSetxxx = [];
    areaSetxxx = areaSetx && areaSetx.filter((item) => {
        const pamdun1 = item.areaNo;
        if (pamdun1 === address) {
            return item
        }
    })

    const values = temtem;
    const token = SPGet('token')
    const email = SPGet('email')
    const meshUUID = SPGet('meshUUID')
    const addrs = address.substring(2, 4) + address.substring(0, 2);
    //这边需要重新写
    meshLog('homelightUtils.js,118行,组是rgb的组的操作', rgbH);
    const opCode = "8277";
    let value1 = Math.ceil(rgbH * 65535);
    let value2 = Math.ceil(areaSetxxx[0].rgbS * 65535);
    let value3 = Math.ceil(areaSetxxx[0].rgbL * 65535);
    const value = getOctets2Msg(value3) + getOctets2Msg(value1) + getOctets2Msg(value2);
    let result = await homeDeng(token, email, meshUUID, addrs, opCode, value);
    const { ctl_status } = result;
    if (ctl_status == 0) {
        //修改localStorage上areaSetx的数据
        let areaitem;
        for (let index = 0; index < areaSetx.length; index++) {
            if (areaSetx[index].areaNo == address) {
                areaitem = areaSetx[index]
            }
        }
        areaitem.rgbH = rgbH
        //meshLog('areaitem', areaitem);
        //saveAreaInfor(areaitem)
        // meshLog("传到页面上需要展示右边数据的组", item);
        PubSub.publish('data', areaitem)
        //修改亮度的背景条颜色
        PubSub.publish('backgroudCololArea', areaitem)
    }


}
